/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.declex.model;

import com.activeharmony.Model;
import com.activeharmony.annotation.Column;
import com.chinasoft_ohos.commontools.toast.Toast;
import com.dspot.declex.annotation.AfterLoad;
import com.dspot.declex.annotation.AfterPut;
import com.dspot.declex.annotation.LocalDBModel;
import com.dspot.declex.annotation.UseModel;

import java.util.List;

import static com.dspot.declex.actions.Action.$Toast;
import static com.dspot.declex.actions.Action.$UIThread;

/**
 * 使用ActiveOhos ORM 操作表，必须继承 model。
 * User setId()报错，这是个BUG
 */
@UseModel //自动生成get set 方法
@LocalDBModel(table = "User")
public class User extends Model {
    @Column
    String name;
    @Column
    String email;
    @Column
    int age;
    @Column
    String description;

    @AfterLoad
    void executeAfterLoad() {//注入之后

    }

    @AfterPut
    void executeAfterPut() {
        $UIThread();
        //样式丑$Toast("save succeed");
        Toast.show("save succeed");
    }
}

